package com.crv.ci.mq.consumer;

import com.crv.ci.mq.Tasker;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

public class ConsumerListener implements MessageListener {
	
//	private static final Logger logger = LoggerFactory.getLogger(ConsumerListener.class);
	private Tasker tasker;

	public ConsumerListener(Tasker tasker)
	{
		this.tasker = tasker;
	}

	public ConsumerListener()
	{
	}
	@Override
	public void onMessage(Message message) {
		
		TextMessage textMessage = (TextMessage)message;
		
		try {
//			logger.info("consumer resive message:{}",textMessage.getText());
			System.out.println(textMessage.getText());
			tasker.receive(textMessage);
		} catch (JMSException e) {
//			logger.error("resive message error!",e);
			System.out.println(e.toString());
		}
	

	}

}
